#include "Log4Cplus.h"

Log4Cplus::Log4Cplus()
{
	time_t curtime=time(0);
	tm tim =*localtime(&curtime); 
	char szPathLog[64] ={0};
	snprintf(szPathLog,sizeof(szPathLog),"%s%d-%d-%d.log",PATH,tim.tm_year+1900,tim.tm_mon+1,tim.tm_mday);

	m_appender =new RollingFileAppender(LOG4CPLUS_TEXT(szPathLog), 1024*1024*5, 14);

	//指定输出模式
	std::string pattern = "[%D{%Y-%m-%d %H:%M:%S %q}] [%-5p] <%l %M> %m%x%n";	
    m_appender->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern)));

	m_logger =Logger::getInstance(LOG4CPLUS_TEXT("Loger"));

	//设置LogLevel
	m_logger.setLogLevel(ALL_LOG_LEVEL);

	//将Appender添加到m_logger上
	m_logger.addAppender(m_appender);

	NDCContextCreator _context("loop");
}

Log4Cplus::~Log4Cplus()
{
	
}

const Logger& Log4Cplus::LogGet()
{
	return m_logger;
}

